{<%
require 'openssl'
require 'time'

def not_after(pem)
  after = 0
  if pem.include? '-----BEGIN CERTIFICATE-----'
    after = OpenSSL::X509::Certificate.new(pem).not_after.utc.iso8601
  end
  after
end

%>
  "director.ssl.cert": "<%= not_after(p("director.ssl.cert", "")) %>",
  "blobstore.tls.cert.ca": "<%= not_after(p("blobstore.tls.cert.ca", "")) %>",
  "director.config_server.ca_cert": "<%= not_after(p("director.config_server.ca_cert", "")) %>",
  "director.config_server.uaa.ca_cert": "<%= not_after(p("director.config_server.uaa.ca_cert", "")) %>",
  "nats.tls.ca": "<%= not_after(p("nats.tls.ca", "")) %>",
  "nats.tls.client_ca.certificate": "<%= not_after(p("nats.tls.client_ca.certificate", "")) %>",
  "nats.tls.director.certificate": "<%= not_after(p("nats.tls.director.certificate", "")) %>",
  "director.db.tls.cert.ca": "<%= not_after(p("director.db.tls.cert.ca", "")) %>",
  "director.db.tls.cert.certificate": "<%= not_after(p("director.db.tls.cert.certificate", "")) %>"
}
